package com.weixing.mall.provider.job;

import cn.hutool.core.collection.CollUtil;
import com.weixing.mall.provider.manager.AgentAuditOrderManager;
import com.weixing.mall.push.GtComponent;
import com.weixing.mall.push.PushMsg;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.quartz.QuartzJobBean;

import java.util.List;

/**
 * 代理商订单审核通知消息任务
 */
public class AgentAuditJob extends QuartzJobBean {
    @Autowired
    private AgentAuditOrderManager agentAuditOrderManager;
    @Autowired
    private GtComponent gtComponent;


    @Override
    protected void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        List<String> auditList = agentAuditOrderManager.needAuditList();
        PushMsg pushMsg = new PushMsg();
        pushMsg.setTitle("订单审核通知");
        pushMsg.setBody("您有待审核的订单请及时审核");
        pushMsg.setClick_type("none");
        agentAuditOrderManager.recordMsg(auditList,pushMsg);
        if (CollUtil.isNotEmpty(auditList)) {
            gtComponent.listCid(pushMsg, auditList);
        }
        System.out.println("代理商晋升通知消息任务已执行");
    }
}
